package com.reider.log4AS3.deciders
{
	import com.reider.log4AS3.dataholder.Level;
	import com.reider.log4AS3.dataholder.LoggerScope;
	
	import flash.utils.Dictionary;

	public class LoggerScopeNode
	{
		public var name:String
		public var parent:LoggerScopeNode
		public var children:Dictionary
		
		private var _size:uint
		private var _scope:LoggerScope
		
		public function get scope():LoggerScope
		{
			return _scope;
		}
		
		public function set scope(value:LoggerScope):void
		{
			_scope = value;
		}
		
		public function LoggerScopeNode(name:String, scope:LoggerScope)
		{
			this.name = name
			this.scope = scope
				
			children = new Dictionary()
		}

		public function hasChild():Boolean
		{
			return Boolean(_size)
		}
		
		public function removeChild(child:LoggerScopeNode):Boolean
		{
			if(children[child.name] == child){
				delete children[child.name]
				child.parent = null
				_size--
				return true
			}else{
				return false
			}
		}
		
		public function getChild(name:String):LoggerScopeNode
		{
			return children[name]
		}
		
		public function addChild(node:LoggerScopeNode):void
		{
			if(children[node.name] === null){
				_size++
			}
			children[node.name] = node
			node.parent = this
		}
	}
}